﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace EthnicEdu.Pages
{
    public partial class UploaderListQuestion : PhoneApplicationPage
    {
        public UploaderListQuestion()
        {
            InitializeComponent();
            App.myService.GetAllQuestionByUserIdAsync(App.AccountID);
            App.myService.GetAllQuestionByUserIdCompleted += new EventHandler<Service.GetAllQuestionByUserIdCompletedEventArgs>(myService_GetAllQuestionByUserIdCompleted);

        }

        void myService_GetAllQuestionByUserIdCompleted(object sender, Service.GetAllQuestionByUserIdCompletedEventArgs e)
        {
            List<Service.View_Question> lstCompleted = e.Result.Where(x => x.QuestionState == 1).ToList();
            List<Service.View_Question>  lstWait =  e.Result.Where(x => x.QuestionState == 2).ToList();
            List<Service.View_Question>  lstFail =  e.Result.Where(x => x.QuestionState == 3).ToList();
            lsCompleted.ItemsSource = lstCompleted;
            lsFail.ItemsSource = lstFail;
            lsWait.ItemsSource = lstWait;
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/Pages/UploaderCreateQuestion.xaml", UriKind.Relative));
        }
    }
}